package Euler145;

import java.util.*;

import ReusableCode.MathFunctions;

public class ReversibleNumbers {
	public static void main(String[] args) {
		Set<Long> reversible = new HashSet<Long>();
		
		for(int i = 10; i<=1000000000;i++)
		{
			if(!reversible.contains(i))
			{		
				long rev = MathFunctions.reverseNumber(i);
				long sum = i + rev;
				int digits[] = MathFunctions.getDigits(sum);
				
				if(String.valueOf(i).length() == String.valueOf(rev).length()){
				
					for(int j = 0; j < digits.length; j++)
					{
						if(digits[j]%2==0)
						{
							break;
						}
						else
						{
							if(j == digits.length-1)
							{
								reversible.add((long)i);
								reversible.add((long)rev);
							}
						}
					}
				}
			}
		}
		
		System.out.println(reversible.size());
	}
}
